import axios, { AxiosInstance } from "axios";
import NProgress from "nprogress";
import 'nprogress/nprogress.css'

const requests:AxiosInstance = axios.create({
    timeout:5000
})

// 请求拦截器
requests.interceptors.request.use(
    config => {
        NProgress.start()
        return config;
    },
    error => {}
  );
// 响应拦截器
requests.interceptors.response.use(
    response => {
        NProgress.done()
        return response.data
    },
    error => {
        return Promise.reject(new Error('faile'))
    }
  );
export default requests;
  